# watches

h, m = list(map(int, input().split()))

if m > 0:
    rm = 60 - m
else:
    rm = 0
    
if h > 0:
    rh = 12 - h
elif m > 0:
    rh = 11
else:
    rh = 0
    rm = 0
    
print(rh, rm)

# empty string
